import 'package:flutter/material.dart';

void main() => runApp(myApp());

class myApp extends StatelessWidget{
  @override
  Widget build(BuildContext context){
    return MaterialApp(
      home:Scaffold(
        appBar: new AppBar(
          title: new Text('水平布局123'),
        ),
        // body: nolh(), //不灵活水平布局
        // body: lhRow(), //灵活水平布局
        body: hyRow(), //灵活不灵活混用
      )
    );
  }
}

// 不灵活水平布局

class nolh extends StatelessWidget{
  @override

  Widget build(BuildContext context){
    return Row(
          children: <Widget>[
            new RaisedButton( //按钮组件
              onPressed: (){},
              color:Colors.yellow,
              child:new Text('第一个按钮')
            ),
            new RaisedButton(
              onPressed: (){},
              color:Colors.green,
              child:new Text('第二个按钮')
            ),
            new RaisedButton(
              onPressed: (){},
              color:Colors.red,
              child:new Text('第三个按钮')
            )
          ],
        );
  }
}

// 灵活的水平布局

class lhRow extends StatelessWidget{
  @override

  Widget build(BuildContext context){
    return Row(
      children: <Widget>[
        Expanded(
          child: new RaisedButton(
            onPressed: (){},
            color:Colors.red,
            child:new Text('红色按钮')
          ),
        ),
        Expanded(
          child: new RaisedButton(
            onPressed: (){},
            color:Colors.yellow,
            child:new Text('黄色按钮')
          ),
        ),
        Expanded(
          child:new RaisedButton(
            onPressed: (){},
            color:Colors.green,
            child:new Text('绿色按钮')
          )
        )
      ],
    );
  }
}

// 混用
class hyRow extends StatelessWidget{
  @override

  Widget build(BuildContext context){
    return Row(
          children: <Widget>[
            new RaisedButton( //按钮组件
              onPressed: (){},
              color:Colors.yellow,
              child:new Text('第一个按钮')
            ),
            Expanded(
              child:new RaisedButton(
                onPressed: (){},
                color:Colors.green,
                child:new Text('第二个按钮')
              ),
            ),
            new RaisedButton(
              onPressed: (){},
              color:Colors.red,
              child:new Text('第三个按钮')
            )
          ],
        );
  }
}